﻿using System;
using System.Collections;
using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
using System.Collections.Generic;
using Huirui.Cavan.Domain.Seedwork;
using Huirui.Cavan.Domain.MainBoundedContext.StockModule;

namespace Huirui.Cavan.Domain.MainBoundedContext.PurchaseModule
{
    #region PurchaseOrder

    /// <summary>
    /// PurchaseOrder object for NHibernate mapped table 'PurchaseOrder'.
    /// </summary>
    [Serializable]
    public class PurchaseOrder : Persistent<string>
    {
        #region Member Variables

        protected DateTime _purchaseDate;
        protected DateTime _deliveryDate;
        protected string _currency;
        protected decimal _currencyRate;
        protected string _supplierInvoiceNumber;
        protected string _deliveryAddress;
        protected string _remark;
        protected string _contact;
        protected string _contactTelephone;
        protected Corporation _corporation;
        protected Employee _purchaseEmployee;
        protected Employee _checkEmployee;
        protected Project _project;
        protected Supplier _supplier;
        protected WareHouse _wareHouse;
        protected SystemIdentifier.CheckedStatus _checkedStatus;
        protected PurchaseIdentifier.StockInStatus _stockInStatus;
        protected IList<Purchase> _purchases;
        protected IList<PurchaseOrderDetail> _purchaseOrderDetails;

        #endregion

        #region Constructors

        public PurchaseOrder() { }

        public PurchaseOrder(string id, DateTime purchaseDate, DateTime deliveryDate, string currency, decimal currencyRate, string supplierInvoiceNumber, string deliveryAddress, string remark, DateTime createDate, DateTime modifyDate, int editUser, Corporation corporation, Employee purchaseEmployee, Project project, Supplier supplier,
            SystemIdentifier.CheckedStatus checkedStatus, PurchaseIdentifier.StockInStatus stockInStatus, Employee checkEmployee, WareHouse wareHouse, string contact, string contactTelephone)
        {
            this.Id = id;
            this._purchaseDate = purchaseDate;
            this._deliveryDate = deliveryDate;
            this._currency = currency;
            this._currencyRate = currencyRate;
            this._supplierInvoiceNumber = supplierInvoiceNumber;
            this._deliveryAddress = deliveryAddress;
            this._remark = remark;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._corporation = corporation;
            this._purchaseEmployee = purchaseEmployee;
            this._project = project;
            this._supplier = supplier;
            this._checkedStatus = checkedStatus;
            this._stockInStatus = stockInStatus;
            this._checkEmployee = checkEmployee;
            this._wareHouse = wareHouse;
            this._contact = contact;
            this._contactTelephone = contactTelephone;
        }

        #endregion

        #region Public Properties


        public virtual DateTime PurchaseDate
        {
            get { return _purchaseDate; }
            set { _purchaseDate = value; }
        }

        public virtual DateTime DeliveryDate
        {
            get { return _deliveryDate; }
            set { _deliveryDate = value; }
        }

        public virtual string Currency
        {
            get { return _currency; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Currency", value, value.ToString());
                _currency = value;
            }
        }

        public virtual decimal CurrencyRate
        {
            get { return _currencyRate; }
            set { _currencyRate = value; }
        }

        public virtual string SupplierInvoiceNumber
        {
            get { return _supplierInvoiceNumber; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for SupplierInvoiceNumber", value, value.ToString());
                _supplierInvoiceNumber = value;
            }
        }

        public virtual string DeliveryAddress
        {
            get { return _deliveryAddress; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for DeliveryAddress", value, value.ToString());
                _deliveryAddress = value;
            }
        }

        public virtual string Remark
        {
            get { return _remark; }
            set
            {
                _remark = value;
            }
        }

        public virtual string Contact
        {
            get { return _contact; }
            set
            {
                _contact = value;
            }
        }

        public virtual string ContactTelephone
        {
            get { return _contactTelephone; }
            set
            {
                _contactTelephone = value;
            }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual Employee PurchaseEmployee
        {
            get { return _purchaseEmployee; }
            set { _purchaseEmployee = value; }
        }

        public virtual Employee CheckEmployee
        {
            get { return _checkEmployee; }
            set { _checkEmployee = value; }
        }


        public virtual Project Project
        {
            get { return _project; }
            set { _project = value; }
        }

        public virtual Supplier Supplier
        {
            get { return _supplier; }
            set { _supplier = value; }
        }

        public virtual WareHouse WareHouse
        {
            get { return _wareHouse; }
            set { _wareHouse = value; }
        }

        public virtual SystemIdentifier.CheckedStatus CheckedStatus
        {
            get { return _checkedStatus; }
            set { _checkedStatus = value; }
        }

        public virtual PurchaseIdentifier.StockInStatus StockInStatus
        {
            get { return _stockInStatus; }
            set { _stockInStatus = value; }
        }

        public virtual IList<Purchase> Purchases
        {
            get
            {
                if (_purchases == null)
                {
                    _purchases = new List<Purchase>();
                }
                return _purchases;
            }
            set { _purchases = value; }
        }

        public virtual IList<PurchaseOrderDetail> PurchaseOrderDetails
        {
            get
            {
                if (_purchaseOrderDetails == null)
                {
                    _purchaseOrderDetails = new List<PurchaseOrderDetail>();
                }
                return _purchaseOrderDetails;
            }
            set { _purchaseOrderDetails = value; }
        }

        #endregion
    }
    #endregion
}